import React from 'react'
import { Route, Switch, Redirect } from 'react-router-dom'
import { Layout, Spin } from 'antd'
import ROUTES from '@utils/routes'
import MENU from '@utils/menu'

import Career from './career/index'
import CareerDetail from './career/detail/index'
import Education from './education/index'
import EducationDetail from './education/detail/index'

const { DATA } = MENU
const { Header, Sider, Content, Footer } = Layout

export default class MchntMgntRoute extends React.Component{
    constructor(props) {
        super(props)
        this.state = {
            menu: []
        }
    }
    componentDidMount() {
        let submenu = DATA.filter(item => {return item.key == '2'})
        if (submenu && submenu[0] && submenu[0].children) {
            this.setState({
                menu: submenu[0].children
            })
        }
    }

    render() {
        var height = document.documentElement.clientHeight || document.body.clientHeight
        height = height - 66
        return (
            <div>
                <Layout>
                    <Content>
                        <div>
                            <Switch>
                                <Route path={ROUTES.JOIN_US.EDUCATION.URL} exact render={()=><Education/>}></Route>
                                <Route path={ROUTES.JOIN_US.EDUCATION.DETAIL.URL} exact render={()=><EducationDetail/>}></Route>
                                <Route path={ROUTES.JOIN_US.CAREER.URL} exact render={()=><Career/>}></Route>
                                <Route path={ROUTES.JOIN_US.CAREER.DETAIL.URL} exact render={()=><CareerDetail/>}></Route>
                                <Redirect to={ROUTES.JOIN_US.EDUCATION.URL}></Redirect>
                            </Switch>
                        </div>
                    </Content>
                </Layout>
            </div>
        )
    }
}